#include<bits/stdc++.h>
using namespace std;
int t;
long long n,m,L,V,d[100010],v[1010],a[2020],p[100010],ans1=0,ans2;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
		cin>>n>>m>>L>>V;
		for(long long i=1;i<=n;i++){
			cin>>d[i]>>v[i]>>a[i];
		}
		for(long long i=1;i<=m;i++){
			cin>>p[i];
		}
		for(long long i=1;i<=n;i++){
			if(v[i]>V&&d[i]<=p[m]) ans1++;
		}
		if(ans1==0) cout<<"0"<<m<<endl;
		else{
		cout<<ans1<<" "<<m-1<<endl;
	    }
		ans1=0;
	}
    return 0;
}
